package com.plugin.manage.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.plugin.core.model.entity.ElderInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * 长者信息Mapper接口
 * 
 * @author mark
 * @date 2025-07-29
 */
@Mapper
public interface ElderInfoMapper extends BaseMapper<ElderInfo> {

    /**
     * 查询总人数
     */
    @Select("SELECT COUNT(*) FROM elder_info WHERE del = 0")
    Long getTotalCount();

    /**
     * 按自理能力分组统计人数
     */
    @Select("SELECT self_care_ability, COUNT(*) as count FROM elder_info WHERE del = 0 AND self_care_ability IS NOT NULL GROUP BY self_care_ability")
    List<Map<String, Object>> getSelfCareAbilityStats();

    /**
     * 按护理等级分组统计人数
     */
    @Select("SELECT care_level, COUNT(*) as count FROM elder_info WHERE del = 0 AND care_level IS NOT NULL GROUP BY care_level")
    List<Map<String, Object>> getCareLevelStats();
}
